package c1703;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.Vector;
 
public class H {
    static class Person {
        String sex;
        double height;
 
        public Person(String sex, double height) {
            this.sex = sex;
            this.height = height;
        }
    }
 
    public static void main(String[] args) {
        List<Person> boys = new Vector<>();
        List<Person> girls = new Vector<>();
        int n = cin.nextInt();
        while (n-- > 0) {
            String sex = cin.next();
            double height = cin.nextDouble();
            if (sex.equals("male")) {
                boys.add(new Person(sex, height));
            } else {
                girls.add(new Person(sex, height));
            }
 
        }
        Collections.sort(boys, (bx, by) -> {
            double dif = bx.height - by.height;
            if (dif > 0) return 1;
            if (dif < 0) return -1;
            return 0;
        });
        Collections.sort(girls, (gx, gy) -> {
            double dif = gy.height - gx.height;
            if (dif > 0) return 1;
            if (dif < 0) return -1;
            return 0;
        });
        for (Person boy : boys) System.out.print(String.format("%.2f", boy.height) + " ");
        for (Person girl : girls) System.out.print(String.format("%.2f", girl.height) + " ");
        cin.close();
        cout.close();
 
    }
 
    static Scanner cin = new Scanner(new BufferedInputStream(System.in));
    static PrintWriter cout = new PrintWriter(new BufferedOutputStream(System.out));
}
